package org.kumas.sgrpc.common.threadpool;

import org.kumas.sgrpc.common.extension.ExtensionLoader;

public class ThreadPool$Adaptive implements ThreadPool {

    public java.util.concurrent.Executor getExecutor(org.kumas.sgrpc.common.URL arg0) {
        if (arg0 == null) {
            throw new IllegalArgumentException("url == null");
        }
        org.kumas.sgrpc.common.URL url = arg0;
        String extName = url.getParameter("threadpool", "FixedThreadPool");
        if (extName == null) {
            throw new IllegalStateException(
                "Failed to get extension (org.kumas.sgrpc.common.threadpool.ThreadPool) name from url ("
                    + url.toString() + ") use keys([threadpool])");
        }
        ThreadPool extension = (ThreadPool) ExtensionLoader
            .getExtensionLoader(ThreadPool.class)
            .getExtension(extName);
        return extension.getExecutor(arg0);
    }

}